package com.hd.assistant.biz.manager;

import org.apache.commons.mail.HtmlEmail;

public class DefaultEmailSendManager {
	
	private String email ="manongsoft@163.com";
	private String password = "xunyu1234";
	private String host = "smtp.163.com";

	public String sendDumpTradesOkEmail(String toEmail){
		String content = "<HTML><BODY><H1><A style='font-size:20px;color:red' href=\"http://121.196.131.205//order/trades.htm\">您的订单已同步成功，详情请点击</A></H1></BODY></HTML>";
		try {
			return send(toEmail, content, "订单挖宝", "订单同步完成通知");
		} catch (Exception e) {
			return null;
		}
	}
	
	public String send(String toEmail,String html,String from,String subject) throws Exception{
		// Create the email message
		  HtmlEmail email = new HtmlEmail();
		  
		  email.setHostName(host);
		  email.setAuthentication(this.email, this.password);//邮件服务器验证：用户名/密码
		  email.setCharset("UTF-8");// 必须放在前面，否则乱码
		 
		  email.addTo(toEmail, "");

		  
		 
		  email.setFrom(this.email, from);
		  email.setSubject(subject);
		  
		
		  
		  // set the html message
		  email.setHtmlMsg(html);

		  // set the alternative message
		  email.setTextMsg("感谢您的试用！");

		  // send the email
		 return  email.send();
	}
	
	public static void main(String[] args) {
		DefaultEmailSendManager emailS = new DefaultEmailSendManager(); 
		System.out.println(emailS.sendDumpTradesOkEmail("manongsoft@qq.com"));
	}
}
